package de.hmm.hwip.messagehandler.service;

import java.util.Hashtable;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import android.util.Log;
import de.hmm.hwip.messagehandler.api.IMessageHandler;

/**
 *  OSGi Activator class for message handler service
 * 
 * @author Johannes Mendel
 * @version 12.10.2012
 *
 */
public class Activator implements BundleActivator {

	/**
	 * osgi service interface for Messagehandler
	 */
	private IMessageHandler service;
	
	/**Class TAG **/
	final String TAG = "MessageHandler";
	
	@Override
	public void start(BundleContext context) throws Exception {
		Log.i(TAG, "--------------> " + TAG + " started <--------------");
		
		service = new MessageHandlerImpl();
		
		// register the service
        Hashtable<String, Object> params = new Hashtable<String, Object>();
        params.put( org.osgi.framework.Constants.SERVICE_PID, IMessageHandler.class.getName());
        params.put( org.osgi.framework.Constants.SERVICE_DESCRIPTION,"Provides IPC Service");
        context.registerService(IMessageHandler.class.getName(), service, params);

	}

	@Override
	public void stop(BundleContext arg0) throws Exception {
		Log.i(TAG, "<-------------- " + TAG + " stopped -------------->");

	}

}
